﻿$("#aGoodOrderSubmit").click(function () {
    $("#aGoodOrderSubmit").attr('disabled', "true");
    var memname = $.trim($("#memname").val());
    var telnumber = $.trim($("#telnumber").val());
    var address = $.trim($("#address").val());
    if (memname == "") { alert("请输入您的姓名!"); return; }
    if (telnumber == "") { alert("请输入您的手机号码!"); return; } else { if (!telnumber.IsMobile()) { alert("您输入的手机号码格式有误"); return; } }
    if (address == "") { alert("请输入您的收货地址!"); return; }

    $.get("../Service/AjaxService.ashx?Method=GoodApplication",
    {
        "MemID": getCookie("uid"),
        "MemName": memname,
        "ExchangeTelePhone": telnumber,
        "ExchangeAddress": address,
        "MicroOrderDiscountMoney": $("#totalMoney").text(),
        "MicroOrderPoint": $("#MicroPoint").val()
    }
    , function (text) {
        if (text == "0") { alert("系统有点繁忙，提交失败！"); } else {
            alert("申请成功!");
            $("#aGoodOrderSubmit2").attr("data-load", "goodspay.aspx?MicroOrderID=" + text);
            //清空localStorage对象
            var strKey = "";
            var getData = "";
            for (var i = localStorage.length - 1; i >= 0; i--) {
                strKey = localStorage.key(i);
                if (strKey.substring(0, 5) == "good_") {
                    getData = JSON.parse(xxl.xd.getValue(strKey));
                    localStorage.removeItem(getData.Type);
                }
            }
            //清空Cookie
            setCookie("goodlist", "");
            $("#aGoodOrderSubmit2").click();
        }
        $("#aGoodOrderSubmit").removeAttr("disabled");
    }, "text")
})
